#include <jni.h>
#include <string>
#include <iostream>
#include <android/log.h>

using namespace std;

#define LOG_TAG "MY_LOG"
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))


extern "C" JNIEXPORT jint
Java_com_example_myapplication_JavaForC_callbackAdd(JNIEnv *env, jobject thiz) {
// TODO: implement callbackAdd()
    jclass jclazz = env->FindClass("com/example/myapplication/JavaForC"); // 得到字节码

// 反射得到方法 签名string  (Ljava/lang/String;)V
    jmethodID method = env->GetMethodID(jclazz, "add", "(II)I");

// jobject objet = env->AllocObject(jclazz);  //实例化

    jint value = env->CallIntMethod(thiz, method, 3, 4);  //成功调用

    LOGI("这是一条信息日志");
    LOGD("这是一条调试日志");

    return value;
}




extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_myapplication_MainActivity_stringFromJNI(JNIEnv *env, jobject thiz, jstring s) {
    string hello = "Hello from C++, zxj";
    string aa = "tttt";

    for (int i = 0; i < aa.length(); ++i) {

    }

    string cstr = env->GetStringUTFChars(s, 0);
    string ee = aa + cstr;
    return env->NewStringUTF(ee.c_str());
}


